﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SydEnergiPrototype.DataAccess;
using SydEnergiPrototype.Kernel;
using SydEnergiPrototype.Model;

namespace SydEnergiPrototype.Logic
{
    public class SaveEntryToDataStoreCommand : ICommand
    {
        private IMemoryDataStore _memoryDataStore;
        public SaveEntryToDataStoreCommand()
        {
            _memoryDataStore = IoCContainer.Get<IMemoryDataStore>();
        }
        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
            var entry = ((Button) parameter).DataContext as Entry;
            _memoryDataStore.Persist(entry);
        }

        public event EventHandler CanExecuteChanged;
    }
}
